package acwing._1_1AlgorithmBasic._5DynamicProgramming;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._5DynamicProgramming
 * @File : Q0004.java
 * @Author : WangRuoyu
 * @Date : 2023/4/6 10:09
 */

import java.io.*;

public class Q0004 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        int N = Integer.parseInt(words[0]);
        int V = Integer.parseInt(words[1]);

        int[] w = new int[N + 1];
        int[] v = new int[N + 1];
        int[] s = new int[N + 1];
        for (int i = 1; i <= N; ++i) {
            words = br.readLine().split(" ");
            v[i] = Integer.parseInt(words[0]);
            w[i] = Integer.parseInt(words[1]);
            s[i] = Integer.parseInt(words[2]);
        }

        // 朴素写法 和完全背包一样
        int[][] f = new int[N + 1][V + 1];
        for (int i = 1; i <= N; ++i) {
            for (int j = 0; j <= V; ++j) {
                for (int k = 0; k <= s[i] && j >= v[i] * k; ++k) {
                    f[i][j] = Math.max(f[i][j], f[i - 1][j - v[i] * k] + k * w[i]);
                }
            }
        }
        System.out.println(f[N][V]);
    }
}

